In [1]:
%matplotlib inline
from ggplot import *
import pandas as pd
We're going to use a subset of the meat
dataset for this example. We're going to use pandas
to switch our data from "wide" to "long" format.
In [2]:
meat_subset = meat[['date', 'beef', 'pork']]
df = pd.melt(meat_subset, id_vars=['date'])
df.head()
Out[2]:
Now we'll setup our aesthetics so date
is the x-axis value, variable
is the color of each line and value
is the y-axis value.
In [3]:
ggplot(df, aes(x='date', y='value', color='variable')) + geom_line()
Out[3]:
In [ ]: